from django.contrib import admin
from models import Publisher, Author, Book

class AuthorAdmin (admin.ModelAdmin):
    list_display = ("first_name", "last_name", "email")
    search_fields = ("first_name", "last_name")

class BookAdmin (admin.ModelAdmin):
    list_display = ("title", "publisher", "publication_date")
    list_filter = ("publication_date",)
    date_hierarchy = "publication_date"
    ordering = ("-publication_date",)
    #fields = ("title", "authors", "publisher", "publication_date")
    filter_horizontal = ("authors",)
    raw_id_fields = ("publisher",)

model_arglists = [
    (Publisher,),
    (Author, AuthorAdmin),
    (Book, BookAdmin),
]
for model_arglist in model_arglists:
    admin.site.register(*model_arglist)
